package org.stvd.entities.common;

import java.io.IOException;
import java.io.Serializable;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;


/**
 * 向前端返回时将Long转成字符串
 * @author houzx
 */
public class LongJsonSerializer extends JsonSerializer<Long> implements Serializable{

    private static final long serialVersionUID = -107051694793943188L;
    
    @Override
    public void serialize(Long value, JsonGenerator jsonGenerator, SerializerProvider serializers)
        throws IOException, JsonProcessingException {
        String text = (value == null ? null : String.valueOf(value));
        if (text != null) {
            jsonGenerator.writeString(text);
        }
    }
}
